home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / DMODP35b.lha / DASModPlayer / Rexx / MakeList2.drx < prev    next >
Text File  |  1994-08-12  |  6KB  |  216 lines

  1. /*
  2.  
  3.    Make Module List 2, D.A.S ModulePlayer REXX-script for making modulelists
  4.    with information like module name, channels and the author.
  5.  
  6.    V0.03 By Erno Tuomainen
  7.    V0.06 By Pauli Porkka
  8.    V0.10 By Pauli Porkka : added real name parsing and then some..
  9.    V0.11 By Pauli Porkka : Added Author name parsing
  10.    V0.12 By Pauli Porkka : Added Channel parsing
  11.    V0.13 By Pauli Porkka : Added better author name parsing
  12.  
  13.    Possibility to print output on screen or to a file.
  14.    Starting and ending positions definable
  15.  
  16.    Listing by author is possible. You don't have to (well...you can't)
  17.    give the full author name found in your authorlisting!!
  18.         Example: You want to have only modules by 
  19.                  "Purple Motion/FC <Jonne Valtonen>"
  20.         You would only have to give name "Purple Motion" to rexx script
  21.         and it would parse the name by itself to find out the real name.
  22.  
  23.     NOTE: I am not very experienced arexx programmer so this script
  24.     may introduce some really horrible pieces of code. Be warned. :)
  25. */
  26.  
  27. OPTIONS Results
  28. ADDRESS 'DASMP'
  29.  
  30. signal on error
  31. signal on syntax
  32. signal on ioerr
  33. signal on break_c
  34. signal on break_d
  35.  
  36. unknownauthor = 'Unknown'
  37.  
  38. indexwidth = 3
  39. namewidth = 24
  40. authorwidth = 40
  41. stylewidth = 15
  42. timewidth = 6
  43. datewidth = 9
  44. realnwidth = 40
  45. chanwidth = 2
  46. MODCOUNT
  47. modcounter=result
  48.  
  49. say ''
  50. say 'Modulelist Generator for D.A.S Moduleplayer, V0.13'
  51. say 'by Erno Tuomainen (to V0.03) & Pauli Porkka (from V0.04-?)'
  52. say ''
  53. say 'You have 'modcounter' modules currently loaded in your list'
  54. call writech(stdout, 'Do you want to list them all (Y/N)? ')
  55. answer = readln(stdin)
  56. answer = upper(answer)
  57. if answer='Y' then do
  58.    startlist = 0
  59.    endlist = modcounter
  60.    END
  61. else DO
  62.    call writech(stdout, 'Enter starting position (0-'modcounter')? ')
  63.    startlist = readln(stdin)
  64.    call writech(stdout, 'Enter ending position ('startlist+1'-'modcounter')? ')
  65.    endlist = readln(stdin)
  66.    END
  67.  
  68. say ''
  69.  
  70. listmode = 'ALL'
  71. call writech(stdout, 'Module list mode, ALL/KNOWN/UNKNOWN/SPECIFIED (A/K/U/S)?')
  72. answer = readln(stdin)
  73. answer = upper(answer)
  74. SELECT 
  75.     WHEN answer='K' then listmode='KNOWN'
  76.     WHEN answer='U' then listmode='UNKNOWN'
  77.     WHEN answer='S' then DO
  78.         listmode='SELECTED'
  79.         call writech(stdout, 'Give author specification (no wildcards): ')
  80.         selauthorname = readln(stdin)
  81.     END
  82.     OTHERWISE
  83. END
  84.  
  85. call writech(stdout, 'Do you want real file names (Y/N)? ')
  86. answerrn = readln(stdin)
  87. answerrn = upper(answerrn)
  88.  
  89. call writech(stdout, 'List to File or Screen (F/S)? ')
  90. answer = readln(stdin)
  91. answer = upper(answer)
  92. if answer='F' then DO
  93.    listfile='YES'
  94.    call writech(stdout, 'Enter pathfilename for the list? ')
  95.    listfilename = readln(stdin)
  96.    END
  97. else
  98.    listfile='NO'
  99. say ''
  100. listheader3 = 'Listing extracted from D.A.S.MP by MakeList.drx V0.13'
  101. listheader1 = left("Num", indexwidth)' 'left("Module name", namewidth)' 'left("Chans", chanwidth+2)' 'left("Author", authorwidth)
  102. listheader2 = '---------------------------------------------------------------------------'
  103.  
  104. if listfile='YES' then DO
  105.    call open(listfilehandle, listfilename, 'W')
  106.    call writeln(listfilehandle, listheader3)
  107.    call writeln(listfilehandle, listheader1)
  108.    call writeln(listfilehandle, listheader2)
  109.    END
  110. else DO
  111.    say listheader3
  112.    say listheader1
  113.    say listheader2
  114.    END
  115.    modulecount=0
  116. DO modspec= startlist to endlist-1
  117.    MOVETO modspec
  118.    GETAUTHOR
  119.    authorspec=result
  120.    AuthorName=authorspec
  121.    Call ParseAuthorName(AuthorName)
  122.    authorspecC=result   /* Parsed (<xx> removed) author spec for printing*/
  123.    PANAuthorName=authorspec
  124.    Call PANParseAuthorName(PANAuthorName)
  125.    authorspec=result    /* Only name or handle remains*/
  126.    SELECT 
  127.         WHEN listmode='ALL' then Call PrintingSystem 
  128.         WHEN ((listmode='KNOWN') & (authorspec ~= 'Unknown')) then CALL PrintingSystem   
  129.         WHEN ((listmode='UNKNOWN') & (authorspec = 'Unknown')) then CALL PrintingSystem       
  130.         WHEN ((listmode='SELECTED') & (authorspec = selauthorname)) then CALL PrintingSystem
  131.     OTHERWISE END
  132. END
  133.  
  134. if listfile='YES' then
  135.    call close(listfilehandle)
  136.  
  137. EXIT
  138.  
  139. error:
  140. syntax:
  141. say 'Error at line 'sigl' in MakeList V0.13'
  142. EXIT
  143.  
  144. break_c:
  145. break_d:
  146. say 'Received a BREAK signal, aborted...'
  147. EXIT
  148.  
  149. ioerr:
  150. say 'I/O Error at line 'sigl
  151. EXIT
  152.  
  153. /* Procedure for printing out the information to screen or file */
  154. PrintingSystem:
  155.       modulecount= modulecount+1
  156.       MODNAME
  157.       namespec=result
  158.       GETCHANS
  159.       chanspec=result
  160.       moduleline = left(modulecount, indexwidth)' 'left(namespec, namewidth)' ['left(chanspec, chanwidth)'] 'left(authorspecC, authorwidth)
  161.           if listfile='NO' then DO
  162.              say moduleline
  163.              if answerrn='Y' then DO
  164.                 MODREALNAME
  165.                 FilePath=result
  166.                 Call ParseFileName(FilePath)
  167.                 realnamespec=result
  168.                 modulelineb = left('  ', indexwidth)' == 'left(realnamespec, realnwidth)
  169.                 say modulelineb
  170.              END
  171.           END
  172.           Else DO
  173.              call writeln(listfilehandle, moduleline)
  174.              if answerrn='Y' then DO
  175.                     MODREALNAME
  176.                     FilePath=result
  177.                     Call ParseFileName(FilePath)
  178.                     realnamespec=result
  179.                     modulelineb = left('  ', indexwidth)' == 'left(realnamespec, realnwidth)
  180.                     call writeln(listfilehandle, modulelineb)
  181.              END
  182.           END
  183.  
  184. /* procedure for returning the real file name of mdoule. Path stripped.*/
  185. ParseFileName: procedure
  186.     parse arg FilePath
  187.     return substr(FilePath, max(lastpos(':', FilePath),lastpos('/', FilePath))+1)
  188.  
  189.  
  190. /* procedure for removing the <xxx> (real author name) if exists*/
  191. ParseAuthorName: procedure
  192.     parse arg AuthorName
  193.     RealNameExists=Index(AuthorName, '<')
  194.         DivPos = pos('<', AuthorName)
  195.     if DivPos = 0
  196.         then return AuthorName
  197.     else
  198.         return strip(left(AuthorName, DivPos-1),'T','<')
  199. /* prcedure for removing the "<xxx>" AND "/xxxx" */
  200. PANParseAuthorName: procedure
  201.     parse arg AuthorName
  202.     Slash=lastpos('/', AuthorName)
  203.     Birdie=lastpos('<', AuthorName)
  204.     
  205.     if ((Slash =0) & (Birdie = 0)) then DO
  206.         RetAuth= AuthorName
  207.     END
  208.     else DO
  209.         DivPos = Slash
  210.         if Slash = 0 
  211.             then DivPos=Birdie
  212.         RetAuth=left(AuthorName,DivPos-1)
  213.     END
  214.         return RetAuth
  215. EXIT
  216.